
/* variablecoding-final.do
Replication File: White Americans' Reactions to Racial Disparities in COVID-19
LaFleur Stephens-Dougan
*/

** The code below reproduces variable coding.
 
** For reproducing the tables and figures in the main text and Appendix, please see the R markdown file "replication-final.Rmd". 

* -------------------- *
* 1. Load the Data 

** To run the code, you must load the "Tess_Covid_update.dta" as shown below 

use "Tess_Covid_update.dta"

* -------------------- *
* 2. Variable Coding 

***********************************
** Creating Experimental Condition 

** creating experimental condition ** 

gen ExperimentalCondition = P_EXP
label variable ExperimentalCondition "ExperimentalCondition"
label define ExperimentalCondition_lbl 1 "Control" 2 "Treatment", modify
label values ExperimentalCondition ExperimentalCondition_lbl  
tab ExperimentalCondition

*Experimenta |
* lCondition |      Freq.     Percent        Cum.
*------------+-----------------------------------
*    Control |        288       48.73       48.73
*  Treatment |        303       51.27      100.00
*------------+-----------------------------------
*      Total |        591      100.00


** creating control and treatment variables **

gen Control = .
replace Control = 1 if ExperimentalCondition == 1
replace Control = 0 if ExperimentalCondition == 2
tab Control 

*    Control |      Freq.     Percent        Cum.
*------------+-----------------------------------
*          0 |        303       51.27       51.27
*          1 |        288       48.73      100.00
*------------+-----------------------------------
*      Total |        591      100.00


gen Treatment = .
replace Treatment = 1 if ExperimentalCondition == 2
replace Treatment = 0 if ExperimentalCondition == 1
tab Treatment

*  Treatment |      Freq.     Percent        Cum.
*------------+-----------------------------------
*          0 |        288       48.73       48.73
*          1 |        303       51.27      100.00
*------------+-----------------------------------
*      Total |        591      100.00

******************************
** Creating Outcome Variables 

** I create two versions of outcome variables: 1) scaled [0,1], 2) dichotomous

** create facemasks **

** The variable is scaled to [0,1]

gen facemasks = .
label variable facemasks "facemasks"
label define facemasks_lbl 1 "Not at all Important"  0 "Extremely Important", modify
label values facemasks facemasks_lbl
replace facemasks = 1 if Q20==5
replace facemasks = .75 if Q20==4
replace facemasks = .5 if Q20==3
replace facemasks = .25 if Q20==2
replace facemasks = 0 if Q20==1
replace facemasks = . if Q20==98


**create facemasks dichotomous**

gen facemasks_dichotomous = .
label variable facemasks_dichotomous "facemasks_dichotomous"
label define facemasks_dichotomous_lbl 1 " Not Important" 0 "Important", modify
label values facemasks_dichotomous facemasks_dichotomous_lbl
replace facemasks_dichotomous = 1 if Q20 == 3 | Q20 == 4 | Q20==5
replace facemasks_dichotomous = 0 if Q20 == 1 | Q20 == 2


** create individualrights**

** The variable is scaled to [0,1]

gen individualrights = .
label variable individualrights "individualrights"
label define individualrights_lbl 1 "Strongly Agree" 0 "Strongly Disagree", modify
label values individualrights individualrights_lbl
replace individualrights = 1 if Q16==1
replace individualrights = .75 if Q16==2
replace individualrights = .5 if Q16==3
replace individualrights = .25 if Q16==4
replace individualrights = 0 if Q16==5
replace individualrights = . if Q16==98

** create individual rights dichotomous**

gen individualrights_dichotomous = .
label variable individualrights_dichotomous "individualrights_dichotomous"
label define individualrights_dichotomous_lbl 1 "Agree" 0 "Disagree", modify
label values individualrights_dichotomous individualrights_dichotomous_lbl
replace individualrights_dichotomous = 1 if Q16 == 1 | Q16 == 2
replace individualrights_dichotomous = 0 if Q16 == 4 | Q16 == 5|Q16 == 3

** create visitparks**

** The variable is scaled to [0,1]

gen visitparks = .
label variable visitparks "visitparks"
label define visitparks_lbl 1 "Allowed Without Any Restrictions" 0 "Complete Restrictions", modify
label values visitparks visitparks_lbl
replace visitparks = 1 if Q23A==1
replace visitparks = .5 if Q23A==2
replace visitparks = 0 if Q23A==3 


** create visitparks_dichotomous**

gen visitparks_dichotomous = .
label variable visitparks_dichotomous "visitparks_dichotomous"
label define visitparks_dichotomous_lbl 1 "Allowed Without Any Restrictions" 0 "Some or Complete Restrictions", modify
label values visitparks_dichotomous visitparks_dichotomous_lbl
replace visitparks_dichotomous = 1 if Q23A == 1 
replace visitparks_dichotomous =0 if Q23A== 2 | Q23A == 3
replace visitparks_dichotomous = . if Q23A==98

*create Follow_Blacks** 

** The variable is scaled to [0,1]

gen Follow_Blacks = .
label variable Follow_Blacks "Follow_Blacks"
label define Follow_Blacks_lbl 1 "Never" 0 "Always", modify
label values Follow_Blacks Follow_Blacks_lbl
replace Follow_Blacks = 1 if Q22A==5
replace Follow_Blacks = .75 if Q22A==4
replace Follow_Blacks = .5 if Q22A==3
replace Follow_Blacks = .25 if Q22A ==2
replace Follow_Blacks = 0 if Q22A==1

**create Follow_Blacks_dichotomous**

gen Follow_Blacks_dichotomous = .
label variable Follow_Blacks_dichotomous "Follow_Blacks_dichotomous"
label define Follow_Blacks_dichotomous_lbl 1 "Never, Some, Half" 0 "Most of the Time, Always", modify
label values Follow_Blacks_dichotomous Follow_Blacks_dichotomous_lbl
replace Follow_Blacks_dichotomous = 0 if Q22A == 1 | Q22A ==2
replace Follow_Blacks_dichotomous = 1 if Q22A == 3 | Q22A ==4 | Q22A == 5


*************************************************
** Creating Moderators & Demographic Variables 

** create hardworkWhites **
gen hardworkWhites = .
label variable hardworkWhites "whites hardworking"
label define hardworkWhites_lbl 0 "Harworking" 1 "Lazy", modify
label values hardworkWhites hardworkWhites_lbl  
replace hardworkWhites =0 if Q6 == 7
replace hardworkWhites = .16666667 if Q6 == 6
replace hardworkWhites = .3333333 if Q6 == 5
replace hardworkWhites = .5 if Q6 == 4
replace hardworkWhites = .6666667 if Q6 == 3
replace hardworkWhites = .8333333 if Q6 == 2
replace hardworkWhites = 1 if Q6 == 1

** create hardworkBlacks**

gen hardworkBlacks = .
label variable hardworkBlacks "blacks hardworking"
label define hardworkBlacks_lbl 0 "Harworking" 1 "Lazy", modify
label values hardworkBlacks hardworkBlacks_lbl 
replace hardworkBlacks =0 if Q5 == 7
replace hardworkBlacks = .16666667 if Q5 == 6
replace hardworkBlacks = .3333333 if Q5 == 5
replace hardworkBlacks = .5 if Q5 == 4
replace hardworkBlacks = .6666667 if Q5 == 3
replace hardworkBlacks = .8333333 if Q5 == 2
replace hardworkBlacks = 1 if Q5 == 1


** create lazystereotype2 **

gen lazystereotype = hardworkWhites - hardworkBlacks
tab lazystereotype
generate lazystereotype2 = lazystereotype
replace lazystereotype2 = 1 if lazystereotype < 0
replace lazystereotype2  = 0 if lazystereotype >=0
tab lazystereotype2

** create intelligentWhites **

gen intelligentWhites = .
label variable intelligentWhites "whites intelligent"
label define intelligentWhites_lbl 0 "Intelligent" 1 "Unintelligent", modify
label values intelligentWhites intelligentsWhites_lbl
replace intelligentWhites = 0 if Q8==7
replace intelligentWhites = .16666667 if Q8 ==6
replace intelligentWhites = .3333333 if Q8 ==5
replace intelligentWhites =.5 if Q8 ==4
replace intelligentWhites =.6666667 if Q8==3
replace intelligentWhites =.8333333 if Q8==2
replace intelligentWhites = 1 if Q8==1
summarize Q8
summarize intelligentWhites

** create intelligentBlacks **

gen intelligentBlacks = .
label variable intelligentBlacks "blacks intelligent"
label define intelligentBlacks_lbl 0 "Intelligent" 1 "Unintelligent", modify
label values intelligentBlacks intelligentBlacks_lbl
replace intelligentBlacks =Q7
tab Q7
replace intelligentBlacks = 0 if Q7==7
replace intelligentBlacks = .16666667 if Q7 ==6
replace intelligentBlacks = .3333333 if Q7 ==5
replace intelligentBlacks =.5 if Q7 ==4
replace intelligentBlacks =.6666667 if Q7==3
replace intelligentBlacks =.8333333 if Q7==2
replace intelligentBlacks = 1 if Q7==1
summarize Q7
summarize intelligentBlacks


** create unintelligentstereotype2 **
generate unintelligentstereotype = intelligentWhites - intelligentBlacks
tab unintelligentstereotype

generate unintelligentstereotype2 = unintelligentstereotype
replace unintelligentstereotype2 = 1 if unintelligentstereotype< 0
replace unintelligentstereotype2 = 0 if unintelligentstereotype >= 0

** Create negstereotpe_endorsement ** 

** This is the variable that will be used in the interactions with the treatments 
generate negstereotype_endorsement = (unintelligentstereotype2 + lazystereotype2)/2
summarize negstereotype_endorsement
label variable negstereotype_endorsement "negative stereotype endorsement"
label define negstereotype_endorsement 0 "did not endorse stereotypes"  1 "endorsed stereotypes", modify
label values negstereotype_endorsement negstereotype_endorsement_lbl

** create gender **
gen gender_new = GENDER
replace gender_new = ((GENDER-1)) if GENDER<98
label define gender_lbl 1 "Female" 0 "Male"
label values gender_new gender_lbl  
tab gender_new

** create party **
gen pid7 = P_PARTYID7
replace pid7 = ((P_PARTYID7-1)/6) if P_PARTYID7<98
label define pid7_lbl 1 "Strong Republican" 0 "Strong Democrat"
label values pid7 pid7_lbl  
tab pid7


** create ideology **
gen ideo5 = P_IDEO
replace ideo5 = . if P_IDEO == 8
replace ideo5 = ((P_IDEO-1)/6) if P_IDEO<8
label define ideo5_lbl 1 "Extrememly Conservative" 0 "Extrememly Liberal"
label values ideo5 ideo5_lbl  
tab ideo5


** create south **
gen South = REGION4
replace South = 1 if REGION4 == 3
replace South = 0 if REGION4 == 1
replace South = 0 if REGION4 == 2
replace South = 0 if REGION4 == 4


** create education ** 
gen educ = EDUC4
replace educ = ((EDUC4-1)/3) if EDUC4<8
label define educ_lbl 1 "Bachelors Degree or Higher" 0 "No HS diploma"
label values educ educ_lbl  
tab educ

** create statemention ** 
generate statemention = 0
replace statemention = 1 if STATE=="NY"
tab STATE
replace statemention = 1 if STATE=="LA"
replace statemention = 1 if STATE=="MI"
replace statemention = 1 if STATE=="IL"

** Pre - Analysis -- Outcomes 

** create us taking measures for covid, dichotomous**
gen usmeasures_dichotomous = .
label variable usmeasures_dichotomous "US Taking Measures for Covid, dichotomous"
label define usmeasures_dichotomous_lbl 1 "Disagree" 0 "Agree", modify
label values usmeasures_dichotomous usmeasures_dichotomous_lbl
replace usmeasures_dichotomous = 0 if Q15 == 1 | Q15 == 2
replace usmeasures_dichotomous = 1 if Q15 == 4 | Q15 == 5 | Q15 == 3

** create importance_home, dichotomous **
gen importancehome_dichotomous = .
label variable importancehome_dichotomous "Importance of People Staying Home, dichotomous"
label define importancehome_dichotomous_lbl 1 "Not Important" 0 "Important", modify
label values importancehome_dichotomous importancehome_dichotomous_lbl
replace importancehome_dichotomous = 0 if Q18 == 1 | Q18 == 2
replace importancehome_dichotomous = 1 if Q18 == 4 | Q18 == 5 | Q18 == 3

** create worrycovid **
gen worrycovid = . 
label variable worrycovid "Worry More About Response to Covid"
label define worrycovid_lbl 0 "Move quickly in loosening restrictions" 1 "Take too long in loosening restrictions"
label values worrycovid worrycovid_lbl
replace worrycovid = 0 if Q21 == 1
replace worrycovid = 1 if Q21 == 2
replace worrycovid = . if Q21 == 98


